/**
 * 将object对象转换成json字符串
 * @param obj
 * @returns {string}
 * @constructor
 */
function ObjectToString(obj){
    var ret='{';
    $.each(obj,function(i,item){
       ret+=i+':"'+item+'",';
    });
    ret+='}';
    return ret;
}

//------ POPUPS ----- //

var POPUP_ONCLOSE_FUNCTION_LABEL = "uu12hjkjksd";
function SET_POPUP_ONCLOSE(f) {
    window.document[POPUP_ONCLOSE_FUNCTION_LABEL] = f;
}

/**
 * default settings string for window.open
 * @param option
 * @constructor
 * @return {string}
 */
function POPUP_SETTING(option){
    var height = 400;
    var width = 500;
    var top = 200;
    var left = 200;
    if(option && (typeof option) === 'object') {
        height = option.height || height;
        width = option.width|| width;
        top = option.top || top;
        left = option.left|| left;
    }
    return  "scrollbars=yes, resizable=yes," +
            "menubar=no,titlebar=no,location=no,toolbar=no," +
            "top="+top+", left="+left+", width="+width+", height="+height+"";
}
var POPUP_CLOSE = function (t) {
    (window.opener.document[POPUP_ONCLOSE_FUNCTION_LABEL]
        || function () {
            console.log('t', t);
            window.close();
//            alert("on close!");
        })(t);
};
var REQUEST_PARAM=function(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
    var r = window.location.search.substr(1).match(reg);
    if (r != null) return unescape(r[2]); return null;
};
